package esempi;

import java.util.*;

public class testList {

	public static void main(String[] args) {
		int[] a = { 5, 13, 12, 4, 1, 8 };

		List<Integer> li = new ArrayList<>();

		LinkedList<Integer> li1 = new LinkedList<>(Arrays.asList(2, 12, 16, 24));

		for (int i = 0; i < a.length; i++) {
			// inserction sort su a
			ListIterator<Integer> lit = li.listIterator();
			boolean flag = false;
			while (lit.hasNext() && !flag) {
				int y = lit.next();
				if (y >= a[i]) {
					lit.previous();
					lit.add(a[i]);
					flag = true;

				}// if

			}// while
			if (!flag)
				lit.add(a[i]);
		}// for
		System.out.println(li);

	}
}
